﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Data;
using System.Data.Sql;
using System.Data.SqlClient;
using System.Collections;
using GPCSC.Web;
using System.Text;
using NickLee.Common;

namespace GPCSC.Web.sjs
{
    public partial class fkls : PageBase
    {
        public StringBuilder xjc = new StringBuilder();//反馈历史
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
                f_build();
            }
        }
        protected void f_build()
        {
            DataSet ds = new DataSet();
            byte[] userInfo = (byte[])base.o_baseTable[c_obj.s_userInfo];
            Hashtable userInfoTable = CompressData.UnCompressHashtable(userInfo);
            Model.CL_USER_S users = (Model.CL_USER_S)userInfoTable["SYS_USER"];
            Hashtable htable = new Hashtable();

            htable.Add("@lgid", users.CL_USER_SOID.ToString());
            ds = new SqlReadXml().ReaderDataSet("sel_TB_HDQK_byuserids", htable);
            if (ds.Tables.Count > 0)
            {

                if (ds.Tables[0].Rows.Count > 0)
                {
                    xjc.Append("<table>");
                    for (int i = 0; i < ds.Tables[0].Rows.Count; i++)
                    {
                        if (ds.Tables[0].Rows[i]["IsBs"].ToString() == "0")
                        {
                            ds.Tables[0].Rows[i]["title"] = "<strong style='color:red;'>未复核</strong>";
                            ds.Tables[0].Rows[i]["titles"] = "<strong style='color:red; cursor:pointer' del='" + ds.Tables[0].Rows[i]["ids"].ToString() + "' type='" + ds.Tables[0].Rows[i]["types"].ToString() + "' onclick='dels(this)'>删除</strong>";
                        }
                        else if(ds.Tables[0].Rows[i]["IsBs"].ToString() == "1")
                        {
                            ds.Tables[0].Rows[i]["title"] = "<strong style='color:blue;'>已复核</strong>";
                            ds.Tables[0].Rows[i]["titles"] = "";
                        }
                        else if(ds.Tables[0].Rows[i]["IsBs"].ToString() == "2")
                        {
                            ds.Tables[0].Rows[i]["title"] = "<strong style='color:blue;'>被退回</strong>";
                            ds.Tables[0].Rows[i]["titles"] = "<strong style='color:red;cursor:pointer' del='" + ds.Tables[0].Rows[i]["ids"].ToString() + "' type='" + ds.Tables[0].Rows[i]["types"].ToString() + "' onclick='dels(this)'>删除</strong>";
                        }
                        int mods = i % 3;
                        switch (mods)
                        {

                            case 0:
                                xjc.Append("<tr>");
                                xjc.Append("<td ><img src=\"image/lb.jpg\" onclick=\"opne('" + ds.Tables[0].Rows[i]["ids"].ToString() + "','" + ds.Tables[0].Rows[i]["types"].ToString() + "','" + ds.Tables[0].Rows[i]["IsBs"].ToString() + "')\" /><br />" + ds.Tables[0].Rows[i]["tjdate"].ToString() + "<br />" + ds.Tables[0].Rows[i]["title"].ToString() + "<br/>" + ds.Tables[0].Rows[i]["titles"].ToString() + "</td>");
                                break;
                            case 1:
                                xjc.Append("<td ><img src=\"image/lb.jpg\" onclick=\"opne('" + ds.Tables[0].Rows[i]["ids"].ToString() + "','" + ds.Tables[0].Rows[i]["types"].ToString() + "','" + ds.Tables[0].Rows[i]["IsBs"].ToString() + "')\"/><br />" + ds.Tables[0].Rows[i]["tjdate"].ToString() + "<br />" + ds.Tables[0].Rows[i]["title"].ToString() + "<br/>" + ds.Tables[0].Rows[i]["titles"].ToString() + "</td>");
                                break;
                            case 2:
                                xjc.Append("<td ><img src=\"image/lb.jpg\" onclick=\"opne('" + ds.Tables[0].Rows[i]["ids"].ToString() + "','" + ds.Tables[0].Rows[i]["types"].ToString() + "','" + ds.Tables[0].Rows[i]["IsBs"].ToString() + "')\" /><br />" + ds.Tables[0].Rows[i]["tjdate"].ToString() + "<br />" + ds.Tables[0].Rows[i]["title"].ToString() + "<br/>" + ds.Tables[0].Rows[i]["titles"].ToString() + "</td>");
                                xjc.Append("</tr>");
                                break;
                        }
                    }
                    xjc.Append("</table>");
                }
            }
        }

        protected void LCallBack_Callback(object sender, NickLee.Web.UI.CallBackEventArgs e)
        {
            try
            {
                string type = e.Parameters[0].ToString();
                if (type=="del")
                {
                    string typ = e.Parameters[2].ToString();
                    string ids = e.Parameters[1].ToString();
                    string ty = "";
                    string tyid = "";
                    if (typ == "1")
                    {
                        ty = "NongCun";
                        tyid = "NCID";
                    }
                    else if (typ == "2")
                    {
                        ty = "SheQu";
                        tyid = "SQID";
                    }
                    else if (typ == "3")
                    {
                        ty = "QiYe";
                        tyid = "QYID";
                    }
                    Hashtable htable = new Hashtable();
                    htable.Add("IsDel", "1");
                    SQLServerDAL.databyhtable dtable = new SQLServerDAL.databyhtable();

                    dtable.databyhtables(htable, "update", ty, tyid, ids);
                    xjc.Clear();
                    f_build();
                    Panel1.RenderControl(e.Output);
         
                }
            }
            catch (Exception ee)
            {
                throw ee;
            }
            finally
            {
              
            }
        }
    }
}